/*
 * MailSender.java
 *
 * Created on 15 de Fevereiro de 2007, 13:42
 */

package cefetpb.pod.agenda.servidor;

import java.util.Properties;
import java.util.Date;
import javax.mail.Message;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

/**
 *
 * @author Rosberg
 * @author Deijiane
 */
public class MailSender {
    
    public static void sendMail(String de, String para, String assunto, String mensagem, String smtpServer) {
        Properties p = new Properties();
        p.put("mail.host", smtpServer);
        
        Session session = Session.getInstance(p, null);
        
        MimeMessage msg = new MimeMessage(session);
        
        try {
            msg.setFrom(new InternetAddress(de));
            msg.setRecipient(Message.RecipientType.TO, new InternetAddress(para));
            msg.setSentDate(new Date());

            msg.setSubject(assunto);
            msg.setText(mensagem);

            Transport.send(msg);
        } catch (Exception ex) {
            ex.printStackTrace();
        } finally {
        }
    }
}